<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>实现电子邮件验证函数</title>
    <script>
        function chkEmail(email) {
            return email != "" && email.indexOf("@") > 0
                && email.indexOf("@") == email.lastIndexOf("@")
                && email.indexOf(".") > email.indexOf("@") + 1
                && email.lastIndexOf(".") != length - 1;
        }
        function Determine() {
            var myemail = document.getElementById('test').value;
            alert(chkEmail(myemail))
        }
    </script>
</head>
<body>
<input id="test" type="text">
<input type="submit" value="提交" onclick="Determine()">
</body>
</html>
